var renderActionGeotrails = new Class({

	initialize: function(paginate, activity_id) {
		
		var myurl       = "index.php?option=com_geotrails&activityId="+activity_id+"&view="+document.getElementById('com_geotrails_view').value+"&layout=default_ajax&format=raw&paginate="+paginate+"&Itemid="+document.getElementById('com_geotrails_itemid').value;
		var search_form = document.getElementById("com_geotrails_search_form");
		var fields      = search_form.getElements('input').filter(function(input) {
			return /radio|checkbox/.test(input.getAttribute('type')) && input.checked;
		}).getProperties('id', 'value');
		
		fields = JSON.encode(fields);

		var packageRequest = new Request.HTML({
			evalScripts: true,
			url: myurl,
			method: 'post',
			data: { "fields":fields },
			update: document.id('com_geotrails_content'),
			
			onRequest: function(){
			},

			onSuccess: function(){
			},

			onFailure: function(){
				document.id('com_geotrails_loading').set('text', 'Error when trying to render the menu');
			}
		});

		packageRequest.send();
	}
});

window.addEvent('domready', function() {
    document.id('com_geotrails_search_form').addEvent('click',function() {
        new renderActionGeotrails(0, document.id('com_geotrails_activity_id').value);
    });
});